<%
# this partial expects:
# * project
# * user
# * issue
-%>
<div id="votes">
  <% if user -%>
    <% if user.voted_for? issue -%>
      <%= image_tag( 'tango/32x32/actions/go-up-disabled.png', :alt => 'You have already voted for' ) %>
      <span class="value"><%= issue.popularity %></span>
      <%= link_to_remote image_tag( 'tango/32x32/actions/go-down.png', :alt => 'Change vote to against' ),
                          :url => {
                              :controller => :issues, :action => :update_actions,
                              :id => issue.local_id, :project_id => project.name,
                              :v => 0
                            },
                          :method => :post %>
  
    <% elsif user.voted_against? issue -%>
      <%= link_to_remote image_tag( 'tango/32x32/actions/go-up.png', :alt => 'Change vote to for' ),
                          :url => {
                              :controller => :issues, :action => :update_actions,
                              :id => issue.local_id, :project_id => project.name,
                              :v => 1
                            },
                          :method => :post %>
      <span class="value"><%= issue.popularity %></span>
      <%= image_tag( 'tango/32x32/actions/go-down-disabled.png', :alt => 'You have already voted against' ) %>
  
    <% else -%>
      <%= link_to_remote image_tag( 'tango/32x32/actions/go-up.png', :alt => 'Vote for' ),
                          :url => {
                              :controller => :issues, :action => :update_actions,
                              :id => issue.local_id, :project_id => project.name,
                              :v => 1
                            },
                          :method => :post %>
      <span class="value"><%= issue.popularity %></span>
      <%= link_to_remote image_tag( 'tango/32x32/actions/go-down.png', :alt => 'Vote against' ),
                          :url => {
                              :controller => :issues, :action => :update_actions,
                              :id => issue.local_id, :project_id => project.name,
                              :v => 0
                            },
                          :method => :post %>
  
    <% end -%>
  <% else -%>
    <%= image_tag( 'tango/32x32/actions/go-up-disabled.png', :alt => 'You must be logged in to vote' ) %>
    <span class="value"><%= issue.popularity %></span>
    <%= image_tag( 'tango/32x32/actions/go-down-disabled.png', :alt => 'You must be logged in to vote' ) %>
  <% end -%>
</div>
